<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学生控制台</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="#">在线考试系统 - 学生控制台</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="exam-list.html">考试列表</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="my-exams.html">我的考试</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="my-grades.html">我的成绩</a>
                    </li>
                </ul>
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="#" id="logout">退出登录</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        <div class="row">
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">待考试</h5>
                        <p class="card-text">待参加考试：<span id="pendingExams">0</span></p>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">已完成考试</h5>
                        <p class="card-text">已完成考试：<span id="completedExams">0</span></p>
                    </div>
                </div>
            </div>
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">平均成绩</h5>
                        <p class="card-text">平均分：<span id="averageScore">0</span></p>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
    <script>
        $(document).ready(function() {
            // 检查登录状态
            $.ajax({
                url: '/on_line_exam_system/user/check-login',
                type: 'GET',
                success: function(response) {
                    if (!response.loggedIn) {
                        window.location.href = '/on_line_exam_system/login.html';
                    }
                }
            });

            // 退出登录
            $('#logout').click(function(e) {
                e.preventDefault();
                $.ajax({
                    url: '/on_line_exam_system/user/logout',
                    type: 'POST',
                    success: function() {
                        window.location.href = '/on_line_exam_system/login.html';
                    }
                });
            });
        });
    </script>
</body>
</html> 